#!/usr/bin/python

#$HeadURL$
#$Id$

from menu import *

import re

import os
import sys
import curses
import curses.wrapper

parser=re.compile("[0-9a-z.-]$")

def new_screen(command,title):
    os.system("screen -t %s %s" % (title,command))

def new_ssh(user_host):
    new_screen("ssh %s" % user_host, user_host)
menu_dict_list = [
    dict(txt="ubuntu.pl", fun=new_ssh, args=("redguy@ubuntu.pl")),
    dict(txt="kijowski.info", fun=new_ssh, args=("redguy@stallman.rootnode.pl")),
    dict(txt="wallnut", fun=new_ssh, args=("root@wallnut")),
    dict(txt="czwarte", fun=new_ssh, args=("matikowy"))
    ]
user_hosts=("redguy@ubuntu.pl","redguy@stallman.rootnode.pl","root@192.168.127.254","matikowy")
print os.environ['HOME']
user_hosts=[user_host[:-1] for user_host in open("%s/.sscreen" % (os.environ['HOME']))]
menu_dict_list=[dict(txt=user_host,fun=new_ssh,args=(user_host)) for user_host in user_hosts]
if __name__ == "__main__":
    if os.environ['TERM']== 'screen':
        m = menu(menu_dict_list)
    else:
        os.system("screen -t %s python %s" % (sys.argv[0],sys.argv[0]))